import { Component, computed } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { inject } from '@angular/core';
import { CommonModule, Location } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NzRateModule } from 'ng-zorro-antd/rate';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { Book } from '../../models/book.model';

@Component({
  selector: 'app-book-detail',
  templateUrl: './book-detail.component.html',
  styleUrls: ['./book-detail.component.less'],
  standalone: true,
  imports: [
    CommonModule,
    FormsModule,
    NzRateModule,
    NzButtonModule,
    NzIconModule,
  ],
})
export class BookDetailComponent {

  book: Book = {
    id: 0,
    title: '',
    author: '',
    status: '',
    expanded: false,
    isbn: '',
    publisher: '',
    publishDate: '',
    description: '',
    price: '',
    rating: '',
  };
  constructor(private _router: Router, private _route: ActivatedRoute, private _location: Location) {

    const result = sessionStorage.getItem("BOOK");
    if (result) {
      this.book = JSON.parse(result);
    }
  }

  goBack() {
   this._location.back()
  }
}
